import Axios from 'axios-observable'
import store from '@/store'

const request = Axios.create({
  baseURL: process.env.VUE_APP_BACKEND,
  timeout: 5000
});

request.interceptors.request.use(
  config => {
    const token = store.getters.token;
    if (token) {
      config.headers['Authorization'] = 'Bearer ' + token
    }
    // console.log(config);
    return config;
  },
  error => {
    console.error(error);
    Promise.reject(error);
  }
);
export default request;
